import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey =
  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDF8tnVzptBVMxSzkvY5M65e8HOp8Zqa\n' +
  '78m8W5UUYMHcaMUVM9zN1a5GY/dN83r2lpNxUkTSgiB6uXzk5e1I0By0bub4ZKmJhX9zE\n' +
  '5L5V0V4WORT80yNaCZW4dvETnAgzH2IZEgGYMBcX060kMX6FzB6TCPr+eBhhQpuSd2+HpatQIDAQAB'

const privateKey = ''

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}
